#include "camerathread.h"


void CameraThread::run()
{
    // 设置线程的 CPU 亲和性
    cpu_set_t cpuset;
    CPU_ZERO(&cpuset);
    CPU_SET(0, &cpuset); // 将线程绑定到 CPU 0

    pthread_t thread = pthread_self();
    int rc = pthread_setaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
    if (rc != 0) {
        qDebug() << "Error calling pthread_setaffinity_np: " << rc;
    }

    // 设置线程的调度策略和优先级
    struct sched_param param;
    param.sched_priority = 99; // 实时优先级
    rc = pthread_setschedparam(thread, SCHED_FIFO, &param);
    if (rc != 0) {
        qDebug() << "Error setting sched param: " << rc;
    }

    // 调用 ImageProcessor 的 triggerLoop 方法
    if (processor_) {
        processor_->triggerLoop();
    }
}
